<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>京东按键输入案例</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
				box-sizing: border-box;
			}
			.box {
				width: 400px;
				height: 100px;
				line-height: 100px;
				margin: 20px auto;
				padding-top: 35px;
				padding-left: 5px;
				background-color: #ccc;
			}
			
			.box input {
				float: left;
				width: 300px;
				height: 30px;
				outline: none;
				padding-left: 5px;
				border: 0;
			}
			
			.box button {
				float: left;
				width: 94px;
				height: 30px;
				color: #fff;
				font-size: 18px;
				/*font-weight: 700;*/
				border: 0;
				outline: none;
				cursor: pointer;
				background-color: #e1251b;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<input type="text" name="" id="" value="" />
			<button>搜索</button>
		</div>
		
		<script type="text/javascript">
			//获取 input 对象
			var ipt = document.querySelector('input');
			
			document.addEventListener('keyup',function(e) {
//				console.log(e.keyCode)
				if(e.keyCode === 83) {
					ipt.focus();
				}
			})
		</script>
	</body>
</html>
